$(".yanzhengma").html(getNum());
//随机生成验证码
$(".yanzhengma").click(function(){
	var num = getNum();
	$(this).html(num);
})

//获取四位数字的随机数
function getNum(){
	var t = Math.ceil(Math.random()*10*1000);
	return t;
}


var cuowu = "必填";
//手机号码验证
$("#usernames").blur(function(){
	var reg = /^1(3|4|5|7|8)\d{9}$/;
	/*var reg1 =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;*/
	var txt = $(this).val();
	
	var cuo = "手机号码";
	if(txt.length == 0){
		$("#usernames-error").html(cuowu);
	}else if(!reg.test(txt)){
		$("#usernames-error").html(cuo);
	}else{
		$("#usernames-error").html("");
	}
})

//验证码效验
$("#yanzheng").blur(function(){
	var yan_value = $(this).val();
	var num_value = $(this).next().next().html();
	var cuo = "验证码不一致";
	if(num_value == yan_value){
		$("#yanzheng-error").html("");
	}else if(yan_value.length==0){
		$("#yanzheng-error").html(cuowu);
	}else{
		$("#yanzheng-error").html(cuo);
	}
})

//密码效验
 $("#lpwd").blur(function(){
 	var pwdValue = $(this).val();
 	var cuo = "密码长度为6~20位"
 	if(pwdValue.length >5 && pwdValue.length<21){
 		$("#lpwd-error").html("");
 	}else if(pwdValue.length == 0){
 		$("#lpwd-error").html(cuowu);
 	}else{
 		$("#lpwd-error").html(cuo);
 	}
 })


//先固定一个名字和密码，记住用户名之后就是在cookie里面在注册一个cookie；
var old_name = "18900000000";
var old_pwd ="111111";
var isChecked = document.getElementById("isRememberUsername");
$(".aa").click(function(){
	if($("#lpwd-error").html()=="" && $("#yanzheng-error").html()=="" && $("#usernames-error").html()=="" &&  $("#lpwd").val()=="111111" && $("#usernames").val()=="18900000000"){
		
		if(isChecked.checked){
			$("#usernames").val(old_name);
			$.cookie("uName","18900000000",{expires:7,path:"/"});
			location.href="indexs.html";
		}else{
			location.href="indexs.html";
		}
		
	}else{
		alert("有错误的信息，检查之后重新填")
	}
})


